<html>
<head><meta charset="utf-8"><title>Updating reverse dependencies using code modification · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Updating.20reverse.20dependencies.20using.20code.20modification.html">Updating reverse dependencies using code modification</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="236087643"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Updating%20reverse%20dependencies%20using%20code%20modification/near/236087643" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Updating.20reverse.20dependencies.20using.20code.20modification.html#236087643">(Apr 25 2021 at 19:31)</a>:</h4>
<p>My crate SNAFU works by creating structs based on the name of enum variants. In the next semver incompatible release, I plan on changing the exact formulation of this. </p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="w"> </span><span class="k">enum</span> <span class="nc">Error</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">Foo</span><span class="p">,</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="c1">// 0.6 creates</span>
<span class="n">Foo</span><span class="w"></span>

<span class="c1">// 0.7 creates</span>
<span class="n">FooSuffix</span><span class="w"></span>
</code></pre></div>
<p>I’d like to help out the 150+ crates that depend on me upgrade to the new version, and I’m looking for suggestions on how to do so. </p>
<p>I already have a script that downloads these dependencies, patches in my local version of the crate and attempts to build it. I can easily add in more steps, but not sure what would be most effective.</p>



<a name="236087881"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Updating%20reverse%20dependencies%20using%20code%20modification/near/236087881" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Updating.20reverse.20dependencies.20using.20code.20modification.html#236087881">(Apr 25 2021 at 19:35)</a>:</h4>
<p>Once I have something that gets all/most of the changes to get a crate to compile, then there’s also the best way of getting it to the downstream maintainers.</p>



<a name="236090115"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Updating%20reverse%20dependencies%20using%20code%20modification/near/236090115" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Henry-Mantilla <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Updating.20reverse.20dependencies.20using.20code.20modification.html#236090115">(Apr 25 2021 at 20:13)</a>:</h4>
<p>What about a <code>0.6.n+1</code> release which emits <code>FooSuffix</code> and then a <code>#[deprecated(...)] use FooSuffix as Foo;</code>? That way all they'd have to do is follow the deprecation warnings (and in an ideal world, a <code>#[deprecated]</code> <code>use</code> alias would be understood by <code>rustc</code> to emit an appropriate fix, that a tool could then even parse and automatically apply).</p>



<a name="236090831"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Updating%20reverse%20dependencies%20using%20code%20modification/near/236090831" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Updating.20reverse.20dependencies.20using.20code.20modification.html#236090831">(Apr 25 2021 at 20:27)</a>:</h4>
<blockquote>
<p>in an ideal world, a #[deprecated] use alias would be understood by rustc to emit an appropriate fix</p>
</blockquote>
<p>if rustc doesn't do this already, can you open an issue for it?</p>



<a name="236095095"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Updating%20reverse%20dependencies%20using%20code%20modification/near/236095095" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Updating.20reverse.20dependencies.20using.20code.20modification.html#236095095">(Apr 25 2021 at 21:27)</a>:</h4>
<blockquote>
<p>all they'd have to do is</p>
</blockquote>
<p>The downside here is, without a very automated process, any friction can result in loss of users. That’s ultimately a motivation behind my efforts. </p>
<p>If rustfix can handle auto fixing a deprecation notice, that could be a great way for me to automate that part of the process though.</p>



<a name="236095425"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Updating%20reverse%20dependencies%20using%20code%20modification/near/236095425" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Updating.20reverse.20dependencies.20using.20code.20modification.html#236095425">(Apr 25 2021 at 21:33)</a>:</h4>
<p><a href="https://doc.rust-lang.org/edition-guide/rust-2018/the-compiler/an-attribute-for-deprecation.html">https://doc.rust-lang.org/edition-guide/rust-2018/the-compiler/an-attribute-for-deprecation.html</a></p>



<a name="236095518"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Updating%20reverse%20dependencies%20using%20code%20modification/near/236095518" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Updating.20reverse.20dependencies.20using.20code.20modification.html#236095518">(Apr 25 2021 at 21:35)</a>:</h4>
<p>Doesn’t look like it’s conducive to machine fixing. Just a free form string</p>



<a name="236095745"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Updating%20reverse%20dependencies%20using%20code%20modification/near/236095745" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Updating.20reverse.20dependencies.20using.20code.20modification.html#236095745">(Apr 25 2021 at 21:38)</a>:</h4>
<p>And it doesn’t warn about use statements it seems <a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=62d0b59a713f200a39a7773268b7fbf1">https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=62d0b59a713f200a39a7773268b7fbf1</a></p>



<a name="236095783"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Updating%20reverse%20dependencies%20using%20code%20modification/near/236095783" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Updating.20reverse.20dependencies.20using.20code.20modification.html#236095783">(Apr 25 2021 at 21:40)</a>:</h4>
<p>Which is fine; I can hack my macro to generate both structs at the same time.</p>



<a name="236096248"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Updating%20reverse%20dependencies%20using%20code%20modification/near/236096248" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Updating.20reverse.20dependencies.20using.20code.20modification.html#236096248">(Apr 25 2021 at 21:48)</a>:</h4>
<p><a href="https://github.com/rust-lang/rustfix/issues/151">https://github.com/rust-lang/rustfix/issues/151</a></p>



<a name="236113639"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Updating%20reverse%20dependencies%20using%20code%20modification/near/236113639" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Updating.20reverse.20dependencies.20using.20code.20modification.html#236113639">(Apr 26 2021 at 02:56)</a>:</h4>
<p>it would be really nice if <code>#[deprecated(renamed = ...)]</code> or something were a thing</p>



<a name="236113640"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Updating%20reverse%20dependencies%20using%20code%20modification/near/236113640" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Updating.20reverse.20dependencies.20using.20code.20modification.html#236113640">(Apr 26 2021 at 02:56)</a>:</h4>
<p>and it would work with rustfix</p>



<a name="236159262"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Updating%20reverse%20dependencies%20using%20code%20modification/near/236159262" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Henry-Mantilla <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Updating.20reverse.20dependencies.20using.20code.20modification.html#236159262">(Apr 26 2021 at 11:47)</a>:</h4>
<p><span class="user-mention silent" data-user-id="209168">Thom Chiovoloni</span> <a href="#narrow/stream/122651-general/topic/Updating.20reverse.20dependencies.20using.20code.20modification/near/236113639">said</a>:</p>
<blockquote>
<p>it would be really nice if <code>#[deprecated(renamed = ...)]</code> or something were a thing</p>
</blockquote>
<p>Yeah <span aria-label="100" class="emoji emoji-1f4af" role="img" title="100">:100:</span> – If crate maintainers prefer to define and offer their own migration rather than the <code>#[deprecated]</code> official mechanism, then it means such mechanism does not fulfill its role.</p>
<hr>
<p><span class="user-mention silent" data-user-id="116155">Jake Goulding</span> <a href="#narrow/stream/122651-general/topic/Updating.20reverse.20dependencies.20using.20code.20modification/near/236095745">said</a>:</p>
<blockquote>
<p>And it doesn’t warn about use statements it seems <a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=62d0b59a713f200a39a7773268b7fbf1">https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=62d0b59a713f200a39a7773268b7fbf1</a></p>
</blockquote>
<p>That's so disappointing; <code>#[deprecate]</code>-ing a <code>use</code> statement would in and of itself already allow Rust to understand that a (deprecated) <em>renaming</em> was taking place <span aria-label="sob" class="emoji emoji-1f62d" role="img" title="sob">:sob:</span></p>
<p>The issue with re-emitting the definition is that the copy-pasted type will be incompatible with the original one. I suggest using a <code>type</code> (and a <code>const</code> if unit struct) to emulate the <code>use</code>: <a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=ac1e0d070ba838247ac3587ca23bbaed">https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=ac1e0d070ba838247ac3587ca23bbaed</a></p>
<hr>
<p>I suggest the following: let's use <code>#[deprecated]</code> with a special hard-coded syntax, and define a general-purpose tool that will parse it and perform the transformations based on that. That could serve as a PoC / polyfill while suggesting the actual <code>#[deprecated(renamed…)]</code> feature be implemented and while waiting for that.</p>



<a name="236159443"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Updating%20reverse%20dependencies%20using%20code%20modification/near/236159443" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Henry-Mantilla <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Updating.20reverse.20dependencies.20using.20code.20modification.html#236159443">(Apr 26 2021 at 11:49)</a>:</h4>
<p><span class="user-mention silent" data-user-id="232545">Joshua Nelson</span> <a href="#narrow/stream/122651-general/topic/Updating.20reverse.20dependencies.20using.20code.20modification/near/236090831">said</a>:</p>
<blockquote>
<p>if rustc doesn't [emit an appropriate fix for deprecated <code>use</code>s] already, can you open an issue for it?</p>
</blockquote>
<p>Yeah, good idea, let's go with a gh issue to begin with <span aria-label="+1" class="emoji emoji-1f44d" role="img" title="+1">:+1:</span></p>
<ul>
<li><a href="https://github.com/rust-lang/rust/issues/84584">https://github.com/rust-lang/rust/issues/84584</a></li>
</ul>



<a name="236175458"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Updating%20reverse%20dependencies%20using%20code%20modification/near/236175458" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Updating.20reverse.20dependencies.20using.20code.20modification.html#236175458">(Apr 26 2021 at 13:39)</a>:</h4>
<blockquote>
<p>and define a general-purpose tool </p>
</blockquote>
<p>Well, I've got a highly-special-purpose tool that's hooking on the "type not found" error messages and then doing some MaGiC string manipulation, so it's not blocking me yet :-)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>